//
//  HUD.swift
//  OnemeetingDemo
//
//  Created by 张衡 on 2019/12/5.
//  Copyright © 2019 www.onemeeting.1meetingIos. All rights reserved.
//

import Foundation

class HUD: NSObject {
    
    class func show(msg:String="",window:NSWindow?=NSApplication.shared.mainWindow) -> () {
        let new = window ?? NSApplication.shared.mainWindow
        if new != nil {
            new!.contentView?.ay.startLoading(message: msg)
        }
        
    }
    
    class func dismiss(window:NSWindow?=NSApplication.shared.mainWindow) {
        
        let new = window ?? NSApplication.shared.mainWindow
        if new != nil {
            new!.contentView!.ay.stopLoading()
        }
    }
}

extension NSViewController {
    
    func hud(msg:String="") {
        if self.view.window != nil {
            HUD.show(msg: msg, window: self.view.window!)
        }
    }
    
    func dismiss() {
        if self.view.window != nil {
            HUD.dismiss(window: self.view.window!)
        }
    }
}
